﻿Public Class IClassLog
    Private cons_manager As ClassConsManager = New ClassConsManager()
    Private Shared filewrite As System.IO.StreamWriter
    Private ErrorFilewrite As System.IO.StreamWriter
    Private InFoFilewrite As System.IO.StreamWriter


    Public Sub log(ByVal message As String, Optional ByVal logLevel As ClassConsManager.LOG_LEVEL = 0)
        '  On Error Resume Next
        Try
            Dim filewrite = My.Computer.FileSystem.OpenTextFileWriter("log.txt", True, System.Text.Encoding.UTF8)

            Select Case logLevel
                Case ClassConsManager.LOG_LEVEL.LOG_LEVEL_ERROR
                    ' Debug.Print(Now() & " " & message)
                    '              filewrite.WriteLine(Now() & " " & message)
                Case ClassConsManager.LOG_LEVEL.LOG_LEVEL_CRITICAL
                    ' Debug.Print(Now() & " " & message)
                    '              filewrite.WriteLine(Now() & " " & message)
                Case Else
                    '  Debug.Print(Now() & " " & message)
                    '          filewrite.WriteLine(Now() & " " & message)
            End Select
            'filewrite.Flush()
            'filewrite.Dispose()
        Catch

        End Try
    End Sub

    Public Sub New()
        If filewrite Is Nothing Then
            filewrite = My.Computer.FileSystem.OpenTextFileWriter("log.txt", False, System.Text.Encoding.UTF8)
            filewrite.WriteLine(Now() & "开始记录")
            filewrite.Flush()
            filewrite.Dispose()
        End If
    End Sub
End Class
